ghidra: initial capa explorer extension MVP #2839
ghidra: initial capa explorer extension MVP #2839vaishakh787 wants to merge 14 commits intomandiant:masterfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Please add bug fixes, new features, breaking changes and anything else you think is worthwhile mentioning to the master (unreleased) section of CHANGELOG.md. If no CHANGELOG update is needed add the following to the PR description: [x] No CHANGELOG update needed
Summary of ChangesHello @vaishakh787, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request lays the foundational architecture for integrating the capa analysis tool directly into Ghidra as a native extension. It transitions the existing script-based workflow into a more robust, installable plugin, providing a dedicated UI component and a menu action to initiate capa analysis. This MVP focuses on establishing the core framework and communication between Ghidra's Java environment and capa's Python logic, setting the stage for comprehensive feature development. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a solid MVP for a capa explorer Ghidra extension. The architecture with a Java Swing UI and a Python backend for analysis is a good approach. My review includes suggestions to clean up some boilerplate code, improve error handling and configuration, and some minor code style points. Specifically, I've pointed out unused template files in the capaexplorer package that should be removed, and suggested improvements for handling Python executable paths and exception logging.
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaProvider.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPythonBridge.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPlugin.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPlugin.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaProvider.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPythonBridge.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPythonBridge.java
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capaexplorer/CapaExplorerPlugin.java
Outdated
Show resolved
Hide resolved
mike-hunhoff
left a comment
There was a problem hiding this comment.
This seems reasonable so far, but we want to utilize PyGhidra to bridge Java and Python. This implementation creates a separate process to run Python. Additionally, the already analyzed Ghidra database (program object) should be passed to capa for analysis, so the initial binary analysis does not need to be completed twice.
| Process process = | ||
| new ProcessBuilder( | ||
| python, | ||
| scriptFile.getAbsolutePath() | ||
| ) | ||
| .redirectErrorStream(true) | ||
| .start(); |
There was a problem hiding this comment.
PyGhidra should serve as the Python <-> Java bridge. Running Python in a separate process doesn't count 🙂
There was a problem hiding this comment.
Thanks for the clarification @mike-hunhoff that makes sense.
You're right: launching Python as a separate process is not the intended model here.
I’ll rework the bridge to use PyGhidra directly for in-process Java ↔ Python execution.
The updated approach will be:
- Use PyGhidra as the execution bridge
- Pass the already-loaded
Programobject into Python - Avoid reloading or reanalyzing the binary
- Reuse the existing Ghidra analysis database for capa
For this draft PR, my goal was to validate extension packaging and UI wiring.
I’ll update the implementation to follow the PyGhidra-based design next.
Thanks for pointing this out — I’ll push an update shortly.
|
Hi @mike-hunhoff , I’ve pushed an update to the draft PR addressing your feedback. The implementation now uses PyGhidra as the Java <-> Python bridge, removes the external Python subprocess, and passes the already-loaded Program object directly into the Python script so the existing analysis database is reused. Please let me know when you have a chance to take another look, and if anything should be adjusted further. |
capa/ghidra/plugin/extension/.gradle/9.2.0/checksums/checksums.lock
Outdated
Show resolved
Hide resolved
capa/ghidra/plugin/extension/src/main/java/capa/ghidra/CapaPlugin.java
Outdated
Show resolved
Hide resolved
8a974a8 to
c93b7db
Compare
CHANGELOG updated or no update needed, thanks! 😄
|
Hey @mike-hunhoff , quick update. I switched execution to GhidraScriptService as suggested and now the full flow works: the script runs in PyGhidra, generates the cache, and the plugin loads it successfully. Next, I’ll integrate real Capa JSON output and expand the results model/UI. Let me know if this direction looks good. |
sounds good @vaishakh787 , I look forward to seeing the UI 🙂 |
|
Also @mike-hunhoff wanted to contact you regarding GSoC 2026. How do i reach out to you? |
Review https://github.com/mandiant/flare-gsoc - this explains everything about the program, including preferred methods for contacting potential mentors. |
ghidra: Implement a capa explorer plugin as a Ghidra extension #1980
Summary
Hey @mike-hunhoff , This PR introduces an initial MVP implementation of a capa explorer Ghidra extension.
The purpose of this draft PR is to validate the overall architecture and
integration approach before implementing full capa analysis functionality.
This work aims to replace the current script-based Ghidra workflow with a
proper, installable Ghidra extension that mirrors the IDA Pro capa explorer
plugin experience.
Current functionality
This MVP confirms that the extension:
Non-goals for this PR
This PR intentionally does not implement:
These will be implemented incrementally after architectural review.
Design notes
without breaking backward compatibility
Repository layout
capa/ghidra/
├── helpers.py
├── plugin/
│ ├── capa_explorer.py # existing script integration
│ └── extension/ # new Ghidra extension (this PR)
│ ├── Module.manifest
│ ├── extension.properties
│ ├── build.gradle
│ ├── data/
│ │ └── python/
│ └── src/
│ └── main/java/capa/ghidra/
Related to #1980
